package com.dzu.medium;

/**
 * @author ZhaoDong
 * @date 2022/12/6 11:23
 * @description 357. 统计各位数字都不同的数字个数
 */
public class Test357 {
    public static void main(String[] args) {
        System.out.println(countNumbersWithUniqueDigits(2));
    }

    // https://leetcode.cn/problems/count-numbers-with-unique-digits/solution/tong-ji-ge-wei-shu-zi-du-bu-tong-de-shu-iqbfn/
    public static int countNumbersWithUniqueDigits(int n) {
        if (n == 0) {
            return 1;
        }
        if (n == 1) {
            return 10;
        }
        int res = 10, cur = 9;
        for (int i = 0; i < n - 1; i++) {
            cur *= 9 - i;
            res += cur;
        }
        return res;

    }
}
